package com.wu.foodsafetyplayer.utils

import android.view.WindowManager
import androidx.fragment.app.FragmentActivity

object PopupUtil {

    /**
     * 此方法用于改变背景的透明度，从而达到“变暗”的效果
     */
    fun backgroundAlpha(context:FragmentActivity,bgAlpha: Float) {

        val lp: WindowManager.LayoutParams = context.window.attributes
        // 0.0-1.0
        lp.alpha = bgAlpha
        context.window.attributes = lp
        // everything behind this window will be dimmed.
        // 此方法用来设置浮动层，防止部分手机变暗无效
        context.window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
    }

}